/*Author: Rony Lahav (ID:043489889)*/

/**
 * Executes AT command - prints AT notification to output file every interval
 */
public class ATManager implements Runnable{
	
	private static int[] intervals;
	private static int count=0;
	private static Logger logger=Logger.getInstance();
	
	public ATManager(int[] intervals){
		this.intervals=intervals;
	}
	
	/*check each second if an AT message needs to be printed
	 * and if so - print the time to output file*/
	public void run(){
		int totalElapsedTime=0;
		while (count<intervals.length && !final_project.isShutDown()){
			if (totalElapsedTime>=intervals[count]){
				logger.printATMsg(intervals[count]);
				++count;
			}
			try {
				++totalElapsedTime;
				Thread.sleep(1000);
			} catch (InterruptedException e) {}
		}
	}

}
